package com.atiguigu.rabbitmq.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/*
* 连接工厂创建信道的工具类
* */
public class RabbitMqUtils {
    public static Channel getChannel() throws IOException, TimeoutException {
        ///连接工厂
        ConnectionFactory factory=new ConnectionFactory();
        //工厂IP 连接RabbitMQ队列
        factory.setHost("127.0.0.1");
        //用户名
        factory.setUsername("admin");
        factory.setPassword("123");
        //创建连接d对象
        Connection connection = factory.newConnection();
        //获取信道
        Channel channel = connection.createChannel();

        return channel;
    }
}
